﻿using System.Linq.Expressions;
using Dyao.Book.Entity;

namespace Dyao.Book.Repository.Abstractions
{
    public interface IBookCatalogueRepository : IDataRepository<BookCatalogueEntity>
    {
        /// <summary>
        /// 批量添加
        /// </summary>
        /// <param name="entities">添加实体</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns></returns>
        Task BulkInsertAsync(IEnumerable<BookCatalogueEntity> entities, CancellationToken cancellationToken = default);

        /// <summary>
        /// 批量更新
        /// </summary>
        /// <param name="entities">添加实体</param>
        /// <param name="updateSelector">选择器</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns></returns>
        Task BulkUpdateAsync(IEnumerable<BookCatalogueEntity> entities, Expression<Func<BookCatalogueEntity, object>> updateSelector, CancellationToken cancellationToken = default);

        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="entities">实体</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns></returns>
        Task BulkDeleteAsync(IEnumerable<BookCatalogueEntity> entities, CancellationToken cancellationToken = default);

        /// <summary>
        /// 根据数据编号获取列表数据
        /// </summary>
        /// <param name="bookId">书籍编号</param>
        /// <param name="selector">选择器</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns></returns>
        Task<List<T>> GetListByBookIdAsync<T>(string bookId, Expression<Func<BookCatalogueEntity, T>> selector, CancellationToken cancellationToken);

        /// <summary>
        /// 根据编号查询数据
        /// </summary>
        /// <param name="ids">编号</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns></returns>
        Task<List<T>> GetListByIdsAsync<T>(List<string> ids, Expression<Func<BookCatalogueEntity, T>> selector, CancellationToken cancellationToken);

        /// <summary>
        /// 根据Id获取实体
        /// </summary>
        /// <param name="id">编号</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns></returns>
        Task<BookCatalogueEntity> GetByIdAsync(string id, CancellationToken cancellationToken);

        /// <summary>
        /// 根据书籍编号获取未匹配的集合
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="bookId">书籍编号</param>
        /// <param name="selector">选择器</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns></returns>
        Task<List<T>> GetNotMatchListByBookIdAsync<T>(string bookId, Expression<Func<BookCatalogueEntity, T>> selector, CancellationToken cancellationToken);

        /// <summary>
        /// 根据书籍编号获取未爬取完成
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="bookId">书籍编号</param>
        /// <param name="selector">选择器</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns></returns>
        Task<List<T>> GetNotCrawlCompalteByBookIdAsync<T>(string bookId, Expression<Func<BookCatalogueEntity, T>> selector, CancellationToken cancellationToken);
    }
}
